<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登陆页面</title>
    <style>
        * {
            user-select: none;
            /* 无法选中，整体感更强 */
        }
        html {
            height: 100%;
        }
        body {
            background-image: url("https://suyu2748.top/images/stadium.jpg");
            background-repeat: no-repeat;
            background-size: 100% 100%;
        }

        .login {
            position: absolute;
            top: 50%;
            margin-top: -200px;
            left: 50%;
            margin-left: -200px;
            /* absolute居中的一种方法 */
            background-color: whitesmoke;
            width: 400px;
            height: 400px;
            border-radius: 25px;
            text-align: center;
            padding: 5px 40px;
            box-sizing: border-box;
            /* 这样padding就不会影响大小 */
        }

        p {
            font-size: 42px;
            font-weight: 600;
        }

        input {
            background-color: whitesmoke;
            width: 100%;
            height: 48px;
            margin-bottom: 10px;
            border: none;
            border-bottom: 2px solid silver;
            /* 下面的会覆盖上面的步伐 */
            outline: none;
            font-size: 22px;
        }

        .btn {
            background-color: #59c2c5;
            width: 38%;
            height: 48px;
            border-radius: 8px;
            margin-top: 40px;
            font-size: 28px;
            font-weight: 600;
            color: white;
        }

        .btn:hover {
            background-color: #59c2a0;
        }
    </style>
</head>
<body>
<h1 style="text-align: center">登录页面</h1>


    <div class="login">
        用户名: <input id="input1" type="text" name="username"/><br>
        密码: <input id="input2" type="password" name="password"/><br>
        <input class="btn" type="button" id="btn01" value="登录">
        <br>
        <a href="/stadium/usermanagement_page/register.html">没有账号，点我注册</a>

    </div>


    <script type="text/javascript" src="https://code.jquery.com/jquery-3.7.0.js"></script>
    <script>
        var student = {};
        var arr = [];
        $(function () {
            $("#btn01").click(function () {
                var nm = $("#input1").val();
                var pw = $("#input2").val();

                var user = {"userAccount": nm, "userPassword": pw};
                $.ajax({
                    type: "post",
                    url: "http://localhost:8080/stadium/common/login",
                    data: JSON.stringify(user),
                    dataType: "json",
                    success: function (data) {
                        console.log(data)
                        if (data != 0) {
                            window.alert("登录成功");
                            if(data == 2)
                            window.location.href = "http://localhost:8080/stadium/reservation_page/user.html";
                            else window.location.href = "http://localhost:8080/stadium/reservation_page/manager.html";
                        } else {
                            window.alert("登录失败");
                        }
                    }
                })
            })
        })
    </script>

</body>
</html>